package com.wnxy.carl.carlorderassembly.controller;


import com.baomidou.mybatisplus.extension.api.R;
import com.wnxy.carl.api.BusinessFlowApi;
import com.wnxy.carl.carlorderassembly.service.IBusinessFlowService;
import com.wnxy.carl.dto.BusinessFlowDTO;
import com.wnxy.carl.dto.PageDTO;
import com.wnxy.carl.param.IncreaseBusinessFlowParam;
import com.wnxy.carl.param.PageParam;
import com.wnxy.carl.response.EPage;
import com.wnxy.carl.response.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 业务订单执行步骤表 前端控制器
 * </p>
 *
 * @author Lucas
 * @since 2021-11-12
 */
@RestController
@RequestMapping("/flow")
@Slf4j
public class BusinessFlowController implements BusinessFlowApi {

    @Resource
    private IBusinessFlowService businessFlowService;
    /**
     * 查看业务流程 List<BusinessFlowDTO>
     * @param pageParam
     * @return
     */
    @Override
    public Result<? extends EPage<BusinessFlowDTO>> seeBusinessFlow(PageParam<Integer> pageParam) {
        log.info("查看业务流程功能：参数={}",pageParam);
        PageDTO<BusinessFlowDTO> pageDTO = businessFlowService.seeBusinessFlow(pageParam);
        return Result.success(pageDTO);
    }

    /**
     * 修改业务流程 BusinessFlowDTO
     * @param flowId
     * @param flowStatus
     * @return
     */
    @Override
    public Result<BusinessFlowDTO> amendBusinessFlow(Integer flowId, Integer flowStatus) {
        log.info("查看业务流程功能：参数={},{}",flowId,flowStatus);
        BusinessFlowDTO businessFlowDTO = businessFlowService.amendBusinessFlow(flowId, flowStatus);
        return Result.success(BusinessFlowDTO.class,"修改成功",businessFlowDTO);
    }

    /**
     *  删除业务流程 Boolean
     * @param flowId
     * @return
     */
    @Override
    public Result cancelBusinessFlow(Integer flowId) {
        log.info("删除业务流程功能：参数={}",flowId);
        businessFlowService.cancelBusinessFlow(flowId);
        return Result.success("删除成功");
    }

    /**
     * 添加业务流程 BusinessFlowDTO
     * @param businessFlowParam
     * @return
     */
    @Override
    public Result<BusinessFlowDTO> increaseBusinessFlow(IncreaseBusinessFlowParam businessFlowParam) {
        log.info("添加业务流程功能：参数={}",businessFlowParam);
        BusinessFlowDTO businessFlowDTO = businessFlowService.increaseBusinessFlow(businessFlowParam);
        return Result.success(BusinessFlowDTO.class,"添加业务流程成功",businessFlowDTO);
    }
}

